//
// Created by wze-zero on 2024/10/24.
//
#include <iostream>

using namespace std;

int digit(int num, int n) {
    if (n == 1) {
        return num % 10;
    } else {
        return num % 10 + digit(num / 10, n - 1) * 10;
    }
}

int main() {
    int num, n;
    cin >> num >> n;
    cout << digit(num, n) << endl;
    return 0;
}